<?php

namespace plugin\admin\app\model;

use plugin\admin\app\model\Base;
use plugin\admin\app\model\traits\MultiLanguage;

/**
 * @property integer $id (主键)
 * @property string $title 公告标题
 * @property string $content 公告内容
 * @property string $created_time 创建时间
 */
class Notice extends Base
{

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'wa_notices';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'id';
    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;

    const TYPE_SYSTEM_NOTICE = 1;

    const TYPE_OFFICAL_NOTICE = 2;

    const TYPE_TRANSFER = 'transfer';

    const TYPE_DOWNLOAD = 'download';

    const TYPE_PAYMENT_DOWNLOAD = 'payment';

    const TYPE_PAYMENT_VIP = 'vip';

    const TYPE_EDIT = 'edit';

    public static function add($userId, $title, $desc, $type, $thirdPartyId = 0)
    {
        return self::insertGetId([
            'user_id' => $userId,
            'title' => $title,
            'third_party_id' => $thirdPartyId,
            'desc' => $desc,
            'type' => $type,
            'created_time' => date('Y-m-d H:i:s'),
            'language' => 'zh'
        ]);
    }

}
